////封装set
let set = (key:string,value:any) => {
    if(key && value){
        ////存储时需要转json
        let value2 = JSON.stringify(value)
        localStorage.setItem(key,value2)
    }else{
        console.error('key和value必须有')
    }
    
}

////封装get
let get = (key:string) => {
    let res = localStorage.getItem(key)
    try{
        ////转换成正常数据
        let res2 = JSON.parse(res!)
        return res2
    }catch(erro){
        console.log(erro);
        return res
    }
}

let rm = (key:string) => {
    localStorage.removeItem(key)
}

export default {
    set,
    get,
    rm
}